<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
    <meta name="author" content="火星科技 http://mars3d.cn " />
    <meta name="apple-touch-fullscreen" content="yes" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="x5-fullscreen" content="true" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
    <!-- 标题及搜索关键字 -->
    <meta name="keywords" content="火星科技,cesium,3D,GIS,marsgis,三维,地球,地图,开发,框架,系统,示例,资料,模型,离线,外包,合肥,安徽,中国" />
    <meta
      name="description"
      content="火星科技 合肥火星 合肥火星科技 合肥火星科技有限公司 leaflet leaflet框架 leaflet开发 cesium cesium开发 cesium框架 三维 地球 模型  gis marsgis 地图离线 地图开发 地图框架 地图外包 框架 开发 外包  地图离线 二维地图 三维地图 全景漫游 地理信息系统 云GIS 三维GIS GIS平台 WebGIS"
    />

    <link rel="shortcut icon" type="image/x-icon" href="https://muyao1987.gitee.io/cdn/marsgis.cn/favicon/favicon.ico" />
    <title>高德路径规划查询(多条) | Mars3D | 三维地图 | 火星科技 | 合肥火星科技有限公司</title>

    <!--第三方lib-->
    <script
      type="text/javascript"
      src="/lib/include-lib.js"
      libpath="/lib/"
      include="jquery,layer,toastr,font-awesome,bootstrap,bootstrap-table,layer,haoutil,mars3d"
    ></script>

    <link href="/css/style.css" rel="stylesheet" />
  </head>

  <body class="dark">


    <div id="mars3dContainer" class="mars3d-container"></div>

    <div class="infoview">
      <table class="mars-table">
        <tr>
          <td>方式</td>
          <td colspan="2">
            <select id="queryType" class="selectpicker form-control">
              <option value="1" selected="selected">步行路线查询</option>
              <!-- <option value="2">骑行路线查询</option> -->
              <option value="3">驾车路线查询</option>
            </select>
          </td>
        </tr>
        <tr>
          <td>起点</td>
          <td>
            <input id="startIpt" type="text" value="" class="form-control" style="width: 200px" />
          </td>
          <td>
            <input type="button" class="btn btn-primary" value="选点" id="startPoint" />
          </td>
        </tr>
        <tr>
          <td>终点：</td>
          <td>查询POI点,共<span style="color: red" id="count">0</span>条</td>
          <td>
            <input type="button" class="btn btn-primary" value="查询" id="endPoint" />
          </td>
        </tr>
        <tr>
          <td></td>
          <td colspan="3">
            <input type="button" class="btn btn-primary" value="开始分析" id="FX" />
            <input type="button" class="btn btn-primary" value="清除" id="clear" />
          </td>
        </tr>
      </table>
    </div>

    <div id="resultView" class="infoview" style="top: 250px; display: none; word-break: break-all; width: 400px">
      <table id="table"></table>
    </div>

    <script src="/js/common.js"></script>
    <script src="./map.js"></script>
    <script type="text/javascript">
      "use script" //开发环境建议开启严格模式

      //当前页面业务相关
      let selectWay
      let start
      let count
      let $table
      let dataSource = []

      function initUI(options) {
        $table = $("#table")
        $table.bootstrapTable({
          height: 300,
          singleSelect: true, //单选
          pagination: false,
          iconsPrefix: "fa",
          columns: [
            {
              field: "index",
              title: "序号",
              sortable: true,
              editable: false,
              align: "left",
              formatter: function (value, row, index) {
                return index + 1
              }
            },
            {
              field: "name",
              title: "目的地",
              sortable: true,
              editable: false,
              align: "left"
            },
            {
              field: "allDistance",
              title: "总距离",
              sortable: true,
              editable: false,
              align: "left"
            },
            {
              field: "allDuration",
              title: "时间",
              sortable: true,
              editable: false,
              align: "left"
            }
          ],
          onClickRow: function (item, $element, field) {
            centerAtRoute(item.graphic)
          }
        })

        $("#queryType").change(function () {
          selectWay = Number($("#queryType").val())
          dataSource = []
          if (start && count != 0) {
            $("#resultView").show()
            selectWay = Number($("#queryType").val())
            btnAnalyse(selectWay, count)
          }
        })

        $("#startPoint").click(function () {
          startPoint().then(function (res) {
            start = res
            $("#startIpt").val(start)
          })
        })

        $("#endPoint").click(function () {
          endPoint()
        })

        //开始分析
        $("#FX").click(function () {
          if (start && count) {
            $("#resultView").show()
            selectWay = Number($("#queryType").val())
          }
          btnAnalyse(selectWay, count)
        })

        $("#clear").click(function () {
          removeAll()
          start = ""
          end = ""
          dataSource = []
          count = ""
          $("#startIpt").val("")
          $("#endIpt").val("")

          $("#resultView").hide()
          $("#count").html("0")
        })
      }

      eventTarget.on("end", (event) => {
        count = event.count
        $("#count").html(count)
      })

      eventTarget.on("analyse", (event) => {
        $("#resultView").show()
        dataSource.push({
          key: event.i,
          index: event.i + 1,
          name: event.name,
          allDistance: event.distance,
          allDuration: event.time,
          graphic: event.id
        })

        $table.bootstrapTable("load", dataSource)
      })
    </script>
  </body>
</html>
